// 	ID : pallab81
// 	PROG : 10453
// 	LANG : C++
// 	2011-08-15-22.27.13 Monday
//
// 	"I have not failed, I have just found 10000 ways that won't work.
//


#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <fstream>
#include <string>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>

#include <ctime>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <climits>
#include <cstring>

using namespace std;

#define CI( x ) scanf("%d",&x)
#define CL( x ) scanf("%lld",&x)
#define CD( x ) scanf("%lf",&x )
#define fo(i,ed) for(int i = 0 ; i < ed ; ++i )
#define foit(i, x) for (typeof((x).begin()) i = (x).begin(); i != (x).end(); i++)
#define bip system("pause")
#define Int long long
#define pb push_back
#define SZ(X) (int)(X).size()
#define LN(X) (int)(X).length()
#define mk make_pair
#define f first
#define s second
#define SET( ARRAY , VALUE ) memset( ARRAY , VALUE , sizeof(ARRAY) )

inline void wait( double seconds ) {
    double endtime = clock() + ( seconds+ CLOCKS_PER_SEC );
    while( clock() < endtime ) {
        ;
    }
}

char line[1010];
int len;
int dp[1010][1010];

inline int go(int l, int r ) {
    if( l >= r ) {
        return 0;
    }
    int &best = dp[ l ][ r ];
    if( best!=-1 ) {
        return best;
    }

    best = (int)1023456789;
    int a = 1+go( l,r-1);
    int b = 1+go(l+1,r);
    best = min( a, b );

    if( line[l]==line[r] ) {
        int c = go( l+1, r-1 );
        best = min( best, c );
    }

    return best;
}
inline void back_track(int l, int r) {
    if( l > r ) {
        ;
    } else if( l == r ) {
        printf("%c",line[l]);
    } else {
        int a = 1+go( l, r-1 );
        int b = 1+go( l+1, r );

        if( line[l]==line[r] ) {
            int c = go(l+1,r-1);
            if( c <= min(a,b) ) {
                printf("%c",line[l]);
                back_track(l+1,r-1);
                printf("%c",line[l]);
            } else if( a <= min(b,c) ) {
                printf("%c",line[r]);
                back_track(l,r-1);
                printf("%c",line[r]);
            } else {
                printf("%c",line[l]);
                back_track(l+1,r);
                printf("%c",line[l]);
            }
        } else {
            if( a <= b ) {
                printf("%c",line[r]);
                back_track(l,r-1);
                printf("%c",line[r]);

            } else {
                printf("%c",line[l]);
                back_track(l+1,r);
                printf("%c",line[l]);
            }
        }
    }
}
inline void Proc() {
    SET( dp, -1 );
    len = strlen(line);
    int to_add = go(0,len-1);

    printf( "%d ", to_add);
    back_track(0,len-1);
    printf("\n");
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt","rt",stdin);
#endif

    while( scanf("%s",line)==1 ) {
        Proc();
    }
    return 0;
}
